public class FilterController
{
	
	public String fieldsOperator {get; set;}
	public String values {get; set;}
	public String query {get; set;}
	
	public void createQuery()
	{
		query = 'Select Name, Id, StartDate from Campaign';
		List<String> fieldsOpr = new List<String>(fieldsOperator.split(';'));
		List<String> comparingValues = new List<String>(values.split(';'));
		
		if(fieldsOpr.size() > 0)
		{
			String whereClause = '';
			if(!fieldsOpr[0].equals(' ') && !fieldsOpr[1].equals(' ') && !comparingValues[0].equals(' '))
			{
				whereClause += fieldsOpr[0]+ ' ' +fieldsOpr[1]+ ' ' +comparingValues[0];
				if(!fieldsOpr[2].equals(' ') && !fieldsOpr[3].equals(' ') && !comparingValues[1].equals(' '))
				{
					whereClause += ' AND '+fieldsOpr[2]+ ' ' +fieldsOpr[3]+ ' ' +comparingValues[1];
					if(!fieldsOpr[4].equals(' ') && !fieldsOpr[5].equals(' ') && !comparingValues[2].equals(' '))
					{
						whereClause += ' AND '+fieldsOpr[4]+ ' ' +fieldsOpr[5]+ ' ' +comparingValues[2];
					}
				}
			}
			if(!whereClause.equals(''))
				query += ' where ' +whereClause;
		}
	}

}